<?php

namespace app\modules\admin\controllers;

use yii;
use yii\helpers\Json;
use app\common\Controller;
use app\common\SystemEvent;
use amnah\yii2\user\models\User;
use amnah\yii2\user\models\UserToken;
use amnah\yii2\user\models\UserAuth;
use yii\web\ForbiddenHttpException;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
use yii\widgets\ActiveForm;
use yii2mod\editable\EditableAction;
use yii2mod\rbac\filters\AccessControl;
use app\models\AcctItemType;
use yii\data\Pagination;

class DashboardController extends Controller
{
    
	public $module;
	public $protected_uids = [];    
	public $superadmin_uid = 0;
	public $loginRedirect = '/admin/dashboard';
	public $defaultAction = 'index';
	public function init()
	{
		parent::init();
//		$this->protected_uids[] = $this->superadmin_uid;//把superadmin 默认加入受保护的列表
		
	}
	
    public function actionMain()
    {
        return $this->render('main');
    }

     public function actionTest()
    {

$query = AcctItemType::find();
 $pagination = new Pagination([
            'defaultPageSize' => 5,
            'totalCount' => $query->count(),
        ]);

$acctItemTypes = $query->orderBy('sort')
            ->offset($pagination->offset)
            ->limit($pagination->limit)
            ->all();
  //      $searchModel = $this->module->model("UserSearch");
    //    $params = Yii::$app->request->getQueryParams();
      //  $dataProvider = $searchModel->search($params);

        return $this->render('test', ['pagination' => $pagination ,
'acctItemTypes' => $acctItemTypes ]);
        //return $this->render('test');
    }

    public function actionIndex()
    {
        $menus = SystemEvent::GetAdminMenu();
        if(Yii::$app->request->isAjax){
            return '<script>OA_Menus='.Json::encode($menus).'</script>';
        }
        return $this->renderPartial('index',['menus'=>$menus]);
    }
}
